<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="/js/jquery-3.5.1.min.js"></script>
    <script src="/js/popper.min.js"></script>
    <script src="js/bootstrap.min.js" type="application/javascript"></script>
<!--    <script src="/secondHand/js/login.js"></script>-->
    <style>
        html,
        body {
            height: 100%;
        }
        body {
            display: -ms-flexbox;
            display: flex;
            -ms-flex-align: center;
            align-items: center;
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #f5f5f5;
        }
        .form-signin {
            width: 100%;
            max-width: 330px;
            padding: 15px;
            margin: auto;
        }
        .form-signin .checkbox {
            font-weight: 400;
        }
        .form-signin .form-control {
            position: relative;
            box-sizing: border-box;
            height: auto;
            padding: 10px;
            font-size: 16px;
        }
        .form-signin .form-control:focus {
            z-index: 2;
        }
        .form-signin input[type="email"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }
        .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
    </style>
</head>
<body >


    <form class="form-signin" method="post" th:action="@{userLogin}" th:object="${user}">
        <img class="mb-4" src="imgs/logo.png" alt="" width="300" height="130">
        <h1 class="h3 mb-3 font-weight-normal">用户登录</h1>
        <label class="sr-only">username</label>

        <input type="text" id="username" class="form-control"  th:field="*{username}"
               placeholder="name" required autofocus>
        <label for="password" class="sr-only">Password</label>
        <input type="password" id="password"   class="form-control" th:field="*{password}"
               placeholder="Password" required>
        <div class="container">
            <input type="text" id="verifyCode"   class="form-control col-sm"
                   placeholder="验证码" required>
            <img class="col-sm" id="myImage" src="" onclick="getVerifyCode()">
        </div>

        <div class="alert alert-danger" role="alert" id="warning" th:if="${message}"
             th:text="${message}"></div>



        <button class="btn btn-success btn-lg btn-block" type="submit">登  录</button>
        <a class="btn btn-warning btn-lg btn-block"  href="register" role="button">注  册</a>

        <p class="text-muted">&copy; 佛大闲置交易论坛</p>
    </form>




</body>
<script>
        getVerifyCode();
        function getVerifyCode() {
            $.ajax({
                type:"get",
                url:"/captchaImage",
                contentType:"application/json;charset=utf-8",
                success:function (data) {
                    document.getElementById("myImage").src="data:image/png;base64,"+ data.img;
                },
                error:function () {
                    alert("error");
                }
            });
        }
    </script>
</html>